home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The PC-SIG Library 9
/
The PC-SIG Library on CD ROM - Ninth Edition.iso
/
401_500
/
DISK0443
/
DISK0443.ZIP
/
TSCORE.S3L
< prev
next >
Wrap
Text File
|
1987-01-09
|
11KB
|
259 lines
SFTRAN3/PDS Level 16-f 01/09/87 14:37 TSCORE.S3I
100 program TSCORE
200 c
300 c Compute weighted average of assignment and test scores, and the
400 c T score where T = 10*((x-mu)/sigma) + 50, mu = mean, sigma =
500 c standard deviation.
600 c
700 c ***** Input **********************************************
800 c
900 c First is a line that is used as a page heading for all output.
1000 c This should not be enclosed in quotes.
1100 c
1200 c Second is number of scores (integer) followed by pairs consisting
1300 c of possible score (integer) and weight (integer), all separated by
1400 c commas.
1500 c
1600 c Remaining inputs each consist of student name in quotes
1700 c (character) followed by student ID number (integer) and all scores
1800 c (integer), with all quantities for each student separated by
1900 c commas.
2000 c
2100 c Fortran list input is used. Therefore, input for each student may
2200 c consist of as many lines as necessary.
2300 c
2400 c Input is terminated by end-of-file.
2500 c
2600 c ***** Output *********************************************
2700 c
2800 c Output consists of the input, with student scores augmented by the
2900 c weighted average of all scores, scaled onto 0% to 100% range
3000 c (identified by Raw% column heading), and the T score (identified
3100 c by T column heading). This output is first printed in the order
3200 c submitted, and second printed in decreasing order of T scores.
3300 c
3400 c ***** Parameters *****************************************
3500 c
3600 c MXSCOR is the maximum number of scores per student. If this
3700 c parameter is made greater than 14 the Format statements in
3800 c procedure (print scores) must be changed.
3900 c MXSTUD is the maximum number of students.
4000 c
4100 parameter (MXSCOR=14)
4200 parameter (MXSTUD=60)
4300 c
4400 c ***** Variables ******************************************
4500 c
4600 c DONE is a signal that end-of-file is present in input.
4700 c I is a loop induction variable.
4800 c ID is the set of student identification numbers.
4900 c INUNIT is the unit number from which to read input.
5000 c INWT is the set of relative weights of assignments and
5100 c examinations.
5200 c J is a loop induction variable.
5300 c K is a loop induction variable.
5400 c LINE is a line of input, containing an input or output file name.
5500 c MU is the mean of composite scores in the RAW vector.
5600 c MUS is an array of means of columns of SCORES.
5700 c NBLANK is the number of blanks required to center a column heading in
5800 c procedure (print scores).
5900 c NSCORE is the number of scores per student (assignments and
6000 c examinations.
6100 c NSTDNT is the number of students.
6200 c OTUNIT is the unit number on which to write output.
6300 c P is a permutation vector used to sort results into descending
6400 c order by T score.
6500 c PAGHDG is printed as a page heading for output.
6600 c RAW is the set of weighted scores, one per student. The RAW score
6700 c for a student is the weighted average of all assignment and
6800 c examination scores.
6900 c SCORES is the set of all scores.
7000 c SIGMA is the unbiased standard deviation of the RAW scores.
7100 c SIGMAS is an array of standard deviations of columns of SCORES.
7200 c SNAME is the set of student names.
7300 c SUMWT is the sum of weights of assignments and examinations. See
7400 c WEIGHT below for explanation of use of SUMWT.
7500 c T is the set of T scores.
7600 c TOP is the set of maximum possible scores for assignments and
7700 c examinations.
7800 c TT is a value of T, used while sorting results by descending
7900 c order of T scores.
8000 c WEIGHT is the set of weights of assignments. WEIGHT is used in
8100 c calculating the RAW score for each student. WEIGHT(I) is
8200 c INWT(I) / (SUMWT * TOP(I)), where all arithmetic is performed
8300 c in floating point. The inner product of TOP and WEIGHT is 1,
8400 c and therefore all elements of RAW are between 0 and 1.
8500 c
8600 character*80 PAGHDG
8700 character*30 SNAME(MXSTUD)
8800 integer I,ID(MXSTUD),INWT(MXSCOR),INUNIT,J,K
8900 character*80 LINE
9000 integer NBLANK,NSCORE,NSTDNT,OTUNIT
9100 integer P(MXSTUD),SCORES(MXSTUD,MXSCOR),SUMWT,TOP(MXSCOR)
9200 logical DONE
9300 real MU,MUS(MXSCOR),RAW(MXSTUD),SIGMA,SIGMAS(MXSCOR),T(MXSTUD)
9400 real TT,WEIGHT(MXSCOR)
9500 c
9600 parameter (INUNIT=10, OTUNIT=11)
9700 c
9800 c ***** Procedures *****************************************
9900 c
10000 c Open input file.
10100 c
10200 do forever
10300 : print *,'Enter input file name, or CON: for input from the'
10400 : print *,'keyboard: '
10500 : read (*,'(a80)') line
10600 : open (inunit,file=line,err=200)
10700 <--exit forever
10800 200 : print *,'Unable to open input file. Try again? '
10900 : read (*,'(a80)') line
11000 <--if (line(1:1).eq.'n'.or.line(1:1).eq.'N') stop
11100 end forever
11200 c
11300 c Open output file.
11400 c
11500 do forever
11600 : print *,'Enter output file name, PRN: for output to the'
11700 : print *,'printer, or CON: for output to the console: '
11800 : read (*,'(a80)') line
11900 : open (otunit,file=line,err=210,carriage control='FORTRAN')
12000 <--exit forever
12100 210 : print *,'Unable to open output file. Try again? '
12200 : read (*,'(a80)') line
12300 <--if (line(1:1).eq.'n'.or.line(1:1).eq.'N') stop
12400 end forever
12500 c
12600 c Read the page heading.
12700 c
12800 read (inunit,'(a80)') paghdg
12900 c
13000 c Read number of scores, followed by possible score and weight for
13100 c each assignment.
13200 c
13300 read (inunit,*) nscore, (top(i),inwt(i), i=1, nscore)
13400 c
13500 c Calculate sum of input weights.
13600 c
13700 sumwt=0
13800 do for i = 1, nscore
13900 : sumwt=sumwt+inwt(i)
14000 end for
14100 c
14200 c Calculate weight = inwt /(top * sum of inwt). Dividing by top
14300 c here saves dividing by top when calculating raw scores.
14400 c
14500 do for i = 1, nscore
14600 : weight(i) = float(inwt(i))/float(top(i)*sumwt)
14700 end for
14800 c
14900 c Make the averages for each assignment (MUS) zero. The total of
15000 c scores for each assignment will be accumulated in MUS, and then
15100 c divided by the number of students to calculate the averages.
15200 c
15300 do for i = 1, nscore
15400 : mus(i) = 0.0
15500 end for
15600 c
15700 c Read scores for each student. Compute the raw score and
15800 c accumulate the sum of raw scores to compute the mean.
15900 c
16000 mu=0.0
16100 nstdnt=0
16200 do forever
16300 : nstdnt=nstdnt+1
16400 : read (inunit,*,done=end) sname(nstdnt), id(nstdnt)
16401 *: , (scores(nstdnt,i), i=1, nscore)
16600 <--if (done) exit forever
16700 : raw(nstdnt)=0.0
16800 : do for i = 1, nscore
16900 : : raw(nstdnt) = raw(nstdnt) + float(scores(nstdnt,i))*weight(i)
17000 : : mus(i) = mus(i) + float(scores(nstdnt,i))
17100 : end for
17200 : mu = mu + raw(nstdnt)
17300 end forever
17400 nstdnt = nstdnt - 1
17500 if (nstdnt.eq.0) then
17600 : print *,' No student scores submitted'
17700 <--stop
17800 end if
17900 if (nstdnt.eq.1) then
18000 : print *,' Scores for only one student submitted'
18100 <--stop
18200 end if
18300 mu = mu/float(nstdnt)
18400 c
18500 c Compute MUS and SIGMAS.
18600 c
18700 do for i = 1, nscore
18800 : mus(i) = mus(i)/float(nstdnt)
18900 : sigmas(i) = 0.0
19000 : do for j = 1, nstdnt
19100 : : sigmas(i) = sigmas(i) + (float(scores(j,i))-mus(i))**2
19200 : end for
19300 : sigmas(i) = sqrt(sigmas(i)/(nstdnt-1))
19400 end for
19500 c
19600 c Compute sigma.
19700 c
19800 sigma=0.0
19900 do for i = 1, nstdnt
20000 : sigma = sigma + (raw(i)-mu)**2
20100 end for
20200 sigma = sqrt(sigma/(nstdnt-1))
20300 c
20400 c Compute T scores.
20500 c
20600 do for i = 1, nstdnt
20700 : t(i) = 10.0*(raw(i)-mu)/sigma+50.0
20800 : p(i) = i
20900 end for
21000 c
21100 c Print results, sort into descending order of T scores, print
21200 c results again.
21300 c
21400 nblank = (5*nscore-27)/2
21500 do (print scores)
21600 do for k = 2, nstdnt
21700 : tt = t(p(k))
21800 : do for j = 1, k-1
21900 : : if (tt.gt.t(p(j))) then
22000 : : : i = p(k)
22100 : : : p(k) = p(j)
22200 : : : p(j) = i
22300 : : : tt = t(i)
22400 : : end if
22500 : end for
22600 end for
22700 do (print scores)
22800 c
22900 write (otunit,'(''1'')')
23000 stop
23100 c
23200 c
23300 procedure (print scores)
23400 : write (otunit,10) paghdg
23500 10 : format ('1',a80)
23600 : write (otunit,20) (' ',i=1,nblank),' Homework and Examinations '
23700 20 : format (t50,70a)
23800 : write (otunit,30) (top(i), i = 1, nscore)
23900 30 : format (t31,'Possible score',t50,14i5)
24000 : write (otunit,40) (inwt(i), i = 1, nscore)
24100 40 : format (t31,'Weight',t50,14i5)
24200 : write (otunit,50) ('-----', i = 1, nscore)
24300 50 : format ('0Student name',t31,' ID Raw% T',t50,14a5)
24400 : write (otunit,'()')
24500 : do for k = 1, nstdnt
24600 : : i = p(k)
24700 : : write (otunit,60) sname(i),id(i),raw(i),t(i)
24701 *: : , (scores(i,j),j=1,nscore)
24900 60 : : format (1x,a30,i5,2pf5.1,0pf5.1,t50,14i5)
25000 : end for
25100 : write (otunit,70) mu,(mus(i),i=1,nscore)
25200 70 : format ('0Mean',t37,2pf5.1,t51,0p14f5.0)
25300 : write (otunit,80) sigma,(sigmas(i),i=1,nscore)
25400 80 : format (' Standard Deviation',t37,2pf5.1,t51,0p14f5.1)
25500 end procedure
25600 c
25700 end program